package com.taofuxn.yycreazy.adpater;

import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.taofuxn.yycreazy.R;
import com.taofuxn.yycreazy.adpater.base.TaofuRecyclerAdapter;
import com.taofuxn.yycreazy.adpater.base.TaofuRecyclerViewHodler;
import com.taofuxn.yycreazy.mvp.model.NewsertJokBean;

import java.util.ArrayList;

/**
 * Created by wanghuafu on 16/9/17.
 */
public class GifJokAdapter extends TaofuRecyclerAdapter<NewsertJokBean.NewsertJokResult.NewsertJok> {

    public GifJokAdapter(int layoutId, ArrayList<NewsertJokBean.NewsertJokResult.NewsertJok> mData) {
        super(layoutId, mData);


    }

    @Override
    protected void convert(TaofuRecyclerViewHodler holder, NewsertJokBean.NewsertJokResult.NewsertJok b) {
        if (!TextUtils.isEmpty(b.updatetime))
            holder.setText(R.id.updateTime, Html.fromHtml("<font color=\"#FF0000\">[更新于 " + b.updatetime + "]</font>").toString());
        holder.setText(R.id.content, b.content);
        if (!TextUtils.isEmpty(b.url)) {
            holder.retrieveView(R.id.itemImg).setVisibility(View.VISIBLE);
            Glide.with(holder.itemView.getContext())
                    .load(b.url)
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    .into((ImageView) holder.retrieveView(R.id.itemImg));
        } else {
            holder.retrieveView(R.id.itemImg).setVisibility(View.GONE);
        }
    }


}
